import React from "react"
import { connect } from "react-redux"
import { bindActionCreators } from 'redux';
import { Button } from 'antd';
import * as react03Actions from "./actions"

class ReactX0301 extends React.Component {
    constructor(props) {
        super(props);
        console.log(this.props)
    }

    render() {
        return (

            <div>
                <h2>{this.props.number}</h2>
                <div className="margin_top_sm">
                    <Button onClick={() => { this.props.counterActions.INCREMENT(2) }} className="margin_right_sm" type="primary">增加</Button>
                    <Button onClick={() => { this.props.counterActions.DECREMENT(2) }} type="primary">减少</Button>
                </div>
            </div>

        )
    }
}
//读数据的方法
const mapStateToprops = (state) => {
    return {
        number: state
    }
}
const setStateToprops = (dispatch) => {
    return {
        counterActions: bindActionCreators(react03Actions, dispatch)
    }
}
//按照顺序
export default connect(mapStateToprops, setStateToprops)(ReactX0301) 